/*TourCMD.java
 * 
 * this command creates a new tour and adds it to the
 * collection of tours within the tourApp
 *
 * Greg Warner
 * Derek Dupuis
 * Michael Dixey
 * Alex Schwartz
 */

import java.util.*;

public class TourCMD extends Cmd
{
   int cap;
   
   public TourCMD() 
   { 
      super(); 
   }
   
   /*make new tour in TourApp*/
   
   public void exec()
   {
      if( token.length >= 6 )
      {
         String tourName = token[ 1 ];
         String compName = token[ 2 ];
         try   //try to format tokens to fields necessary
         {
            cap = Integer.parseInt( token[ 3 ] );
         }
         catch ( NumberFormatException e ) //catch exception if bad token
         {
            System.err.print( "Tour line has bad format!\n" );
            return;
         }
         
         String city = token[4];
         String state = token[5];
         
         
         Tour newTour = new Tour( tourName, compName, cap, city, state );
         tourApp.addTour( newTour );
      }
      else
      {
         System.err.print( "Not enough tokens on tour line!\n" );
         return;
      }
   }
}